package com.yanwq.sayhi.repository;

import com.yanwq.sayhi.bean.Club;
import com.yanwq.sayhi.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 作者：yanweiqiang。
 * 日期：2016/6/16 0016。
 */
@Repository
public interface ClubRepo extends CrudRepository<Club, Long> {

    @Query(value = "select c from club c where c not in (select cv.club from club_vip cv where cv.user=?1)")
    Page<Club> listByUnUser(User user, Pageable pageable);

    Page<Club> findByNameOrderByCreateTimeDesc(String name, Pageable pageable);

    Page<Club> findByOrderByCreateTimeDesc(Pageable pageable);

    Page<Club> findByPermissionOrderByCreateTimeDesc(int permission, Pageable pageable);
}
